<cfcomponent displayname="Termination" output="true">
   
    <cfscript>
        this.DOMAINCONTROLLER = '10.100.1.101';
        this.ORG_SCF = '117';
        this.DOLLARS = "2";
        this.SERVICE_ACCOUNT = "SCFAdmin";
        this.Error = "False";
        this.EmpStatusReason = "none";
        this.TermReqID = "-1";
        this.Home = "";
        this.ArchiveDir = "";
        this.ArchiveEmailDir = "";
        this.RootArchiveDir = "\\scfappshare\ITS_Data\Archive\";
        this.ErrorMessage = "";
        this.Manual = 0;
        this.Scheduled = False;
        this.SysScheduled = False;
        this.SysScheduledTermDate = '';
        this.ScheduledTermDate = '';
        this.TermDateCheck = '';
        this.SysTermDateCheck = '';
        this.SysTermSchedule = ArrayNew(1);
        this.TermSchedule = ArrayNew(1);
        this.DISABLED_USERS_CONTAINER = "OU=Disabled Users,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com";
        this.ARCHIVED_USERS_CONTAINER = "OU=Archived_Users,OU=SCF,OU=SCFUsers,DC=SouthcentralFoundation,DC=com";
        this.SCFAccount = 1;
        this.TermVerbage = '';
        this.TermBody = '';
        this.SysTermVerbage = '';
        this.SysTermBody = '';
        this.NonSCF = 0;
    </cfscript>

      
	<cffunction name="init" access="public" output="false" returntype="Termination">
        <cfargument name="TermReqID" type="string" required="no" default="-1">
        <cfargument name="Manual" type="numeric" required="no" default="0">
        
        <cfscript>
            this.Manual = ( ARGUMENTS.Manual eq 1 ? "True" : "False" );
            ( ARGUMENTS.TermReqID NEQ -1 ? setTermReqID(ARGUMENTS.TermReqID) : "");
            return this;
        </cfscript>
	</cffunction>    
  
        
    <cffunction name="getTermReqID" access="public" output="false" returntype="string">
        <cfreturn this.TermReqID />
    </cffunction>
    
    
    <cffunction name="setTermReqID" access="public" output="false" returntype="void">
        <cfargument name="TermReqID" type="string" required="true" default="-1" />
        <cftry>
            <cfscript>
                import models.*;
                KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
                AD = CreateObject("component", "code_lib.SCF_ActiveDirectory");
                this.TermReqID = ARGUMENTS.TermReqID;
                this.TermDetails = EntityLoadByPK("TerminationRequests", this.TermReqID);
                StepAction = ORMExecuteQuery("FROM StepActions WHERE ActTimeStamp IS NULL AND TermReqID = ? AND StepID = 22", [this.TermReqID] );
                if( !ArrayLen(StepAction) ){
                    StepAction = ORMExecuteQuery("FROM StepActions WHERE ActTimeStamp IS NULL AND TermReqID = ? AND StepID = 23", [this.TermReqID] );
                }
                this.StepAction = StepAction[1];
                if( !this.TermDetails.getNonSCF() ){
                    this.Employee = KronosQueries.funcGetAllEmployees( this.TermDetails.getRosettaID() );
                    this.Supervisor = KronosQueries.funcGetCurrentEmployeeByID( this.Employee.SupervisorIdNo );               
                    this.NonSCF = 0;
                }else{
                    this.Employee = KronosQueries.funcGetAllNonSCFEmployees( this.TermDetails.getRosettaID() );
                    EmployeeDN = AD.getUserDNByAccountName( this.Employee.UserAccount );
                    EmployeeAD = AD.getUserAttributesByDN( EmployeeDN, 'displayname, sAMAccountName, manager');
                    ManagerAD = AD.getUserAttributesByDN( EmployeeAD.manager, 'displayname, sAMAccountName');
                    ManagerRosetta = ORMExecuteQuery("FROM RosettaStone WHERE UserAccount = ?", [ManagerAD.sAMAccountName] );
                    Manager = KronosQueries.funcGetAllEmployees( ManagerRosetta[1].getRosettaID() );
                    this.Supervisor = KronosQueries.funcGetCurrentEmployeeByID( Manager.HRProd_PersonIDNo );
                    this.NonSCF = 1;
                }
                this.RehireEligible = this.TermDetails.getRehireElig();
                this.Home = "\\scfusershare\home\#this.Employee.UserAccount#\";
                this.ArchiveDir = this.RootArchiveDir & "#this.Employee.UserAccount#" & DateFormat(this.TermDetails.getTermDate(), 'YYYYMMDD') & "\";
                this.ArchiveEmailDir = this.ArchiveDir & "Email\";
                this.Home = "\\scfusershare\home\#this.Employee.UserAccount#\";
                this.ARCHIVED_USERS_CONTAINER = GetUserDNArchivedContainer( this.Employee.UserAccount ).ArchivedUsersContainer;
                this.UserDN = GetUserDNArchivedContainer( this.Employee.UserAccount ).UserDN;
                this.SCFAccount = ( Left(this.Employee.UserAccount, 4) NEQ "ANMC" ? "True" : "False" );
                
                //check to see if termination is scheduled or not, and if employee is SCF or NONSCF.  IF 'yes' then schedule the term.
                if( this.NonSCF == 0){
                    this.TermDateCheck = dateFormat( DateAdd('d', 1, this.TermDetails.getTermDate()) , "m/d/yyyy") GT dateFormat(now(), "m/d/yyyy");
                    this.SysTermDateCheck = dateFormat( DateAdd('d', 1, this.TermDetails.getSysTermDate()) , "m/d/yyyy") GT dateFormat(now(), "m/d/yyyy");                
                    if( this.TermDateCheck ){
                        this.Scheduled = True;                    
                        this.TermSchedule = ORMExecuteQuery("FROM TerminationSchedule WHERE TermReqID = ? AND TermDate = '#dateFormat( DateAdd('d', 1, this.TermDetails.getTermDate()) , "m/d/yyyy")#'", [this.TermReqID] );
                        this.TermVerbage = "The Termination has been scheduled for " & dateFormat(this.TermDetails.getTermDate(), "m/d/yyyy") & " and no further action is required on your part.";
                        this.TermBody = "Scheduled";                    
                        if( ArrayLen(this.TermSchedule) eq 0 ){
                            //create sheduled entry of one doesn't exist
                            ts = EntityNew("TerminationSchedule");
                            ts.setTermReqID(this.TermReqID);
                            ts.setTermDate( dateFormat( DateAdd('d', 1, this.TermDetails.getTermDate()) , "m/d/yyyy") );
                            ts.setComplete( 0 );                        
                            this.ScheduledTermDate = dateFormat( DateAdd('d', 1, this.TermDetails.getTermDate()) , "m/d/yyyy");
                            EntitySave(ts, true);
                        }else{
                            this.ScheduledTermDate = dateFormat(this.TermSchedule[1].getTermDate(), 'MM/DD/YYYY');
                        }                    
                    }else{
                        this.Scheduled = False;
                        this.ScheduledTermDate = False;
                    }
                    
                    //Check to see if HR termination is scheduled or not.  IF 'yes' then schedule the term.
                    if( this.SysTermDateCheck ){
                        this.SysScheduled = True;
                        this.SysTermSchedule = ORMExecuteQuery("FROM TerminationSchedule WHERE TermReqID = ? AND SysTermDate = '#dateFormat( DateAdd('d', 1, this.TermDetails.getSysTermDate()) , "m/d/yyyy")#'", [this.TermReqID] );
                        this.SysTermVerbage = "The Termination has been scheduled for " & dateFormat(this.TermDetails.getSysTermDate(), "m/d/yyyy") & " and no further action is required on your part.";
                        this.SysTermBody = "Scheduled";                    
                        if( ArrayLen(this.SysTermSchedule) eq 0 ){
                            //create sheduled entry of one doesn't exist
                            sts = EntityNew("TerminationSchedule");
                            sts.setTermReqID(this.TermReqID);
                            sts.setSysTermDate( dateFormat( DateAdd('d', 1, this.TermDetails.getSysTermDate()) , "m/d/yyyy") );
                            sts.setComplete( 0 );                        
                            this.SysScheduledTermDate = dateFormat( DateAdd('d', 1, this.TermDetails.getSysTermDate()) , "m/d/yyyy");
                            EntitySave(sts, true);
                        }else{
                            this.SysScheduledTermDate = dateFormat(this.SysTermSchedule[1].getSysTermDate(), 'MM/DD/YYYY');
                        }                    
                    }else{
                        this.SysScheduled = False;
                        this.SysScheduledTermDate = False;
                    }
                    
                    //if this is a manual termination, then no schedule
                    if( this.Manual ){
                        this.Scheduled = False;
                        this.ScheduledTermDate = False;
                        this.SysScheduled = False;
                        this.SysScheduledTermDate = False;
                    }
                }
            </cfscript>    
	        
        <cfcatch type="any">
            <cfset this.ErrorMessage = CFCATCH />
        </cfcatch>
        </cftry>       
        <cfreturn />
    </cffunction>
    
    
    
    <cffunction name="setUserAccount" access="public" output="false" returntype="void">
        <cfargument name="UserAccount" type="string" required="true" default="-1" />
        <cftry>
            <cfscript>
                import models.*;
                AD = CreateObject("component", "code_lib.SCF_ActiveDirectory");
                this.UserDN = AD.getUserDNByAccountName( arguments.UserAccount );
                EmployeeAttrs = AD.getUserAttributesByDN( this.UserDN );
                this.Home = "\\scfusershare\home\#arguments.UserAccount#\";
                this.ArchiveDir = this.RootArchiveDir & "#arguments.UserAccount#" & DateFormat(now(), 'YYYYMMDD') & "\";
                this.ArchiveEmailDir = this.ArchiveDir & "Email\";
                this.Home = "\\scfusershare\home\#arguments.UserAccount#\";
                this.ARCHIVED_USERS_CONTAINER = GetUserDNArchivedContainer( arguments.UserAccount ).ArchivedUsersContainer; 
                this.Employee.FirstName = EmployeeAttrs.GivenName;
                this.Employee.LastName = EmployeeAttrs.sn;
                this.Employee.UserAccount = arguments.UserAccount;
            </cfscript>    
            
        <cfcatch type="any">
            <cfset this.ErrorMessage = CFCATCH />
        </cfcatch>
        </cftry>       
        <cfreturn />
    </cffunction>
    
  
    <cffunction name="ADDisable" access="public" output="true" returntype="any">        
        <cfscript>
            Var ADResult = '';
            var retObj = { Status = 'None', Message = '', Result = 0 };
        </cfscript>        
        <cftry>            
            <cfscript>
                if( Not this.Scheduled ){
                    retObj.Result = funcADDisable(this.Employee.UserAccount);
                    retObj.Status = "Completed";
                    retObj.Message = "<strong>Success</strong>";
                    
                    if( retObj.Result NEQ 0 ){
                        retObj.Status = 'Completed';
                        retObj.Message = '<strong>Error Disabling the AD account: #this.Employee.UserAccount#<BR /> 
                            Result:  #replace(retObj.Status,"\'","'","all")#<BR />
                            Step ID: #this.StepAction.getStepActionsID()#<BR />
                            Action by User (Rosetta ID): #Session.UserRosettaID#</strong>
                            Please take the following steps:<BR />
                            1) Disable the Account<Br />
                            2) Scramble the PW<Br />
                            3) Hide from Address List (under "Exchange Advanced")<br />
                            Result: #retObj.Result#';
                        ServiceDeskErrorEmail("EPAR Error:  Processing AD account for Termination/Layoff", retObj.Message);
                    }else{
                        retObj.Status = 'Completed';
                        retObj.Message = "<strong>Success</strong>";
                    }
                    
                }else{
                    retObj.Message = "<strong>Scheduled for #dateFormat(this.TermDetails.getTermDate(), 'm/d/yyyy')#</strong>";
                    retObj.Status = 'Completed';
                }
            </cfscript>

	        <cfcatch type="any">
	            <cfscript>
	               retObj.Status = 'Fail';
                   retObj.Result = 'Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                   retObj.Message = '<strong>Error Disabling the AD account: #this.Employee.UserAccount#<BR /> #retObj.Result#';
                   ServiceDeskErrorEmail("EPAR Error:  Processing AD account for Termination/Layoff", retObj.Message);
                   return retObj;
	            </cfscript>  
	        </cfcatch>                    
        </cftry>
        <cfscript>
           return retObj;
        </cfscript>
    </cffunction> 
    
    
    <cffunction name="HomeFolderArchive" access="public" output="true" returntype="any">   
        <cfscript>
            Var HomeFolderResult = '';
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            var index = 0;
            var objResult = { Result = 0, Error = ""};
        </cfscript> 
            
        <cftry>
            <cfif Not this.Scheduled >
                <cfif this.EmpStatusReason NEQ 57><!--- summer layoff's don't need home folder archived --->
                    <cfif DirectoryExists(this.ArchiveDir)>                        
                        <cfset objResult = funcArchiveHomeFolder(this.Home, this.ArchiveDir) />
                        <cfset HomeFolderResult = objResult.Result />
                        <cfset retObj.Result = objResult.Result />                    
                        <cfset retObj.Message = '<strong>Success</strong>' />
                        <cfset retObj.Status = 'Completed' />
                    <cfelse>
                        <cfdirectory action="create" directory="#this.ArchiveDir#">
                        <cfdirectory action="create" directory="#this.ArchiveEmailDir#">                   
                        <cfset objResult = funcArchiveHomeFolder(this.Home, this.ArchiveDir) />
                        <cfset HomeFolderResult = objResult.Result />
                        <cfset retObj.Result = objResult.Result />                    
                        <cfset retObj.Message = '<strong>Success</strong>' />
                        <cfset retObj.Status = 'Completed' />
                    </cfif>
                </cfif>
            <cfelse>
                <cfif this.EmpStatusReason NEQ 57 >
                    <cfset retObj.Message = "<strong>Scheduled for #dateFormat( this.TermDetails.getTermDate(), 'm/d/yyyy')#</strong>" />
                    <cfset retObj.Result = HomeFolderResult />
                    <cfset retObj.Status = 'Completed' />
                <cfelse>
                    <cfset retObj.Message = "<strong>Summer Layoff.  Home Folder Archive N/A.</strong>" />
                    <cfset retObj.Result = HomeFolderResult />
                    <cfset retObj.Status = 'Completed' />
                </cfif>
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                   retObj.Status = 'Fail' ;
                   retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                   retObj.Message = '<strong>Error Archiving Home Directory: #this.Employee.UserAccount#<BR /> #retObj.Result#';
                   ServiceDeskErrorEmail("EPAR Error:  Error Archiving Home Directory for Termination/Layoff", retObj.Message);
                   return retObj;
                </cfscript>    
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="HRDisable" access="public" output="true" returntype="any">
        <cfscript>
            Var HRResult = '';
            var SQL = "";
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            Var objResult = { Result = 0, Error = ""};
            Var ActionID = 0;
        </cfscript>
            
        <cftry>
        
            <cfscript>
                if( this.TermDetails.getEmpStatusIDNo() NEQ -10132 ){
                    //Terminate (see tActions)
                    ActionID = 5;
                }else{
                    //Place on Leave (see tActions)
                    ActionID = 2;
                }
            </cfscript>

            <cfif Not this.SysScheduled>
                <cfset objResult = funcHRTerm(
                    this.Employee.PersonIDNo, 
                    this.TermDetails.getEmpStatusIDNo(), 
                    this.ORG_SCF,
                    this.RehireEligible,
                    this.TermDetails.getTermTypeID(),
                    this.TermDetails.getEmpStatusReasonCode(),
                    ActionID,
                    DateFormat(this.TermDetails.getTermDate(),'m/d/yyyy'),
                    DateFormat(this.TermDetails.getCOBRAEndOfMonth(),'m/d/yyyy')) />                                             
                <cfset retObj.Result = objResult.Result />                 
                <cfset retObj.SQL = objResult.SQL />
                <cfset retObj.Status = 'Completed' />
                <cfset retObj.Message = "<strong>Success</strong>" />             
            <cfelse>
                <cfset retObj.Status = 'Completed' />
                <cfset retObj.Message = "<strong>Scheduled for #DateFormat(this.TermDetails.getSysTermDate(),'m/d/yyyy')#</strong>" />                 
            </cfif>
            
            <cfif retObj.Result EQ 0>
                
            <cfelse>
                <cfset HRResult = "The termination action on HR record was not successful.  Please check the record in the Kronos HR tools and" & " fix manually if necessary.<BR/>" />
                <cfset retObj.Result = HRResult />
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                    retObj.Message = 'Error Terminating the Kronos HR Prod record: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error:  Terminating Kronos HR Prod Record", retObj.Message);            
                    return retObj;
                </cfscript> 
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="TimeKeeperDisable" access="public" output="true" returntype="any">
        <cfscript>
            Var TimeKeeperResult = '';
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            Var objResult = { Result = 0, Error = ""};
        </cfscript>

        <cftry>
            <cfif Not this.SysScheduled>
                <cfif this.EmpStatusReason NEQ 57><!--- summer layoff check--->
                    <cfset funcDisableTimeKeeper(val(this.Employee.WFC_PersonID))>
                    <cfset retObj.Message = '<strong>Success</strong>' />
                    <cfset retObj.Status = 'Completed' />
                </cfif>
            <cfelse>
                <cfif this.EmpStatusReason NEQ 57> <!--- summer layoff check --->
                    <cfset retObj.Message = "<strong>Scheduled for #dateFormat(this.TermDetails.getSysTermDate(), 'm/d/yyyy')#</strong>" />
                    <cfset retObj.Status = 'Completed' />
                <cfelse>
                    <cfset retObj.Message = "<strong>Summer Layoff.  Disabling TimeKeeper Record N/A.</strong>" />
                    <cfset retObj.Status = 'Completed' />
                </cfif>
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                    retObj.Message = 'Error Disabling TimeKeeper Record: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error:  Disabling TimeKeeper Record", retObj.Message);            
                    return retObj;
                </cfscript>
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="EmailExport" access="public" output="true" returntype="any">
        <cfscript>
            Var EmailExportResult = '';
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            Var objResult = { Result = 0, Error = ""};
        </cfscript>
        
        <cftry>
    
            <cfif Not this.Scheduled>
                <cfif this.EmpStatusReason NEQ 57><!--- summer layoff check--->
                    <cfif Not DirectoryExists(this.ArchiveEmailDir) >
                        <cfdirectory action="create" directory="#this.ArchiveEmailDir#" />
                    </cfif>                    
                    <cfset funcExportMailbox(this.Employee.UserAccount,this.ArchiveEmailDir) />
                    <cfset retObj.Result = 0>
                    <cfset retObj.Message = "<strong>Success</strong>" />
                    <cfset retObj.Status = 'Completed' />                    
                </cfif>
            <cfelse>
                <cfif this.EmpStatusReason NEQ 57> <!--- summer layoff check --->
                    <cfset retObj.Message = "<strong>Scheduled for #dateFormat(this.TermDetails.getTermDate(), 'm/d/yyyy')#</strong>" />
                    <cfset retObj.Status = 'Completed' />                            
                <cfelse>
                    <cfset retObj.Message = "<strong>Summer Layoff.  Mailbox Export N/A.</strong>" />
                    <cfset retObj.Status = 'Completed' />                         
                </cfif>
            </cfif>
            
            <cfif objResult.Result NEQ 0>
                <cfset EmailExportResult = replace(replace(replace(replace(objResult.Error, chr(13),'<BR/>','all'), chr(10), '','all'),'<BR/>',''),'<BR/><BR/>','')  />                
                <cfif this.EmpStatusReason NEQ 57><!--- Notify service desk for action to be performed manually--->
                    <cfset AlertEmail("EPAR Termination:  #this.Employee.FirstName# #this.Employee.LastName# (#this.Employee.UserAccount#)", 
                        'Please export the mailbox for the following employee:
                        #this.Employee.FirstName# #this.Employee.LastName# (Account: #this.Employee.UserAccount#)<BR /><BR />
                        Error Text: #EmailExportResult#') />
                    <cfset retObj.Message = "<strong>#EmailExportResult#</strong>" />
                    <cfset retObj.Status = 'Fail' />                  
                </cfif>
            <cfelseif objResult.Result EQ "">
                <cfset retObj.Message = "<strong>Success</strong>" />
                <cfset retObj.Status = 'Completed' />     
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                    retObj.Message = 'Error Exporting mailbox for Termination/Layoff: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error:   Exporting mailbox for Termination/Layoff", retObj.Message);            
                    return retObj;
                </cfscript>  
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="UserAccountDisable" access="public" output="true" returntype="any">
        <cfscript>
            Var ArchAcctResult = '';
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            Var objResult = { Result = 0, Error = ""};
        </cfscript>
        
        <cftry>
  
            <cfif Not this.Scheduled>
                <cfif this.EmpStatusReason NEQ 57><!--- summer layoff check--->
                    <cfset objResults.Result = funcArchiveAndDisable(this.Employee.UserAccount) /> 
                    <cfset retObj.Result = objResults.Result />
                    <cfset retObj.Status = 'Completed' />
                    <cfset retObj.Message = "<strong>Success</strong>" />                          
                </cfif>
            <cfelse>
                <cfif this.EmpStatusReason NEQ 57> <!--- summer layoff check --->
                    <cfset retObj.Message = "<strong>Scheduled for #dateFormat(this.TermDetails.getTermDate(), 'm/d/yyyy')#</strong>" />
                    <cfset retObj.Status = 'Completed' />                            
                <cfelse>
                    <cfset retObj.Message = "<strong>Summer Layoff.  Account Archive N/A.</strong>" />
                    <cfset retObj.Status = 'Completed' />
                </cfif>
            </cfif>
            
            <cfif objResult.Result NEQ 0>
                <cfset ArchAcctResult = replace(replace(replace(replace(objResult.Error, chr(13),'<BR/>','all'), chr(10), '','all'),'<BR/>',''),'<BR/><BR/>','')  />                
                <cfif this.EmpStatusReason NEQ 57><!--- Notify service desk for action to be performed manually--->
                    <cfset AlertEmail("EPAR Termination:  #this.Employee.FirstName# #this.Employee.LastName# (#this.Employee.UserAccount#)", 
                        'Please following employee object to the Archived_Users container:  #this.Employee.FirstName# #this.Employee.LastName# (Account: #this.Employee.UserAccount#)<BR /><BR />
                        Error Text: #ArchAcctResult#') />
                    <cfset retObj.Message = ArchAcctResult />
                    <cfset retObj.Status = 'Fail' />                  
                </cfif>
            <cfelseif objResult.Result EQ "">
                <cfset retObj.Message = "<strong>Success</strong>" />
                <cfset retObj.Status = 'Completed' />     
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                    retObj.Message = 'Error Archiving the Account for Termination/Layoff: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error:   Archiving the Account for Termination/Layoff", retObj.Message);            
                    return retObj;
                </cfscript>
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="RosettaDisable" access="public" output="true" returntype="any">
        <cfscript>
            Var RosettaResult = '';
            Var retObj = { Status = 'None', Message = '', Result = 0 };
            Var objResult = { Result = 0, Error = ""};
            Var Employee = {UserAccount = this.Employee.UserAccount, FirstName = this.Employee.FirstName, LastName = this.Employee.LastName};
        </cfscript>
        
        <cftry>    
            <cfif Not this.Scheduled>
                <cfif this.EmpStatusReason NEQ 57><!--- summer layoff check--->
                    <cfset funcDisableRosetta(this.TermDetails.getRosettaID()) />
                    <cfset retObj.Status = 'Completed' />
                    <cfset retObj.Message = "<strong>Success</strong>" />
                </cfif>
            <cfelse>
                <cfif this.EmpStatusReason NEQ 57> <!--- summer layoff check --->
                    <cfset retObj.Message = "<strong>Scheduled for #dateFormat(this.TermDetails.getTermDate(), 'm/d/yyyy')#</strong>" />
                    <cfset retObj.Status = 'Completed' />                            
                <cfelse>
                    <cfset retObj.Message = "<strong>Summer Layoff only - No Rosetta action required.</strong>" />
                    <cfset retObj.Status = 'Completed' />                         
                </cfif>
            </cfif>
            <cfset supervisorEmail = ( this.Supervisor.UserAccount EQ "" ? "bfrick@scf.cc" : "#this.Supervisor.UserAccount#@scf.cc") />
            <cfset AlertEmail("Employee Termination Update", 
                "<p>The request to #( this.EmpStatusReason NEQ 57 ? "terminate the employee" : "place the employee in 'Summer Layoff' status")#, 
                    <strong>#Employee.FirstName# #Employee.LastName#</strong>, is complete. #this.TermVerbage# Here is some information regarding their action. <BR />
                </p>
                <table>
                    <tr>
                        <td width=5>&nbsp;</td>
                        <td>Network User Account:</td>
                        <td width=25>&nbsp;</td>
                        <td>#Employee.UserAccount#</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td> 
                            <cfif this.EmpStatusReason EQ 57>  
                                Summer Layoff Date: 
                            <cfelse>
                                Termination Date:
                            </cfif>                         
                        </td>
                        <td>&nbsp;</td>
                        <td>#dateFormat(this.TermDetails.getTermDate(), 'm/d/yyyy')# <strong>(#this.TermBody#)</strong></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>COBRA Exp Date:</td>
                        <td>&nbsp;</td>
                        <td>#DateFormat(this.TermDetails.getCOBRAEndOfMonth(),'m/d/yyyy')#</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>Rehire Elig:</td>
                        <td>&nbsp;</td>
                        <td>#( this.TermDetails.getRehireElig() eq 1 ? "Yes" : "No" )#</td>
                    </tr>
                </table>", 'EPAR_Termination@scf.cc', 'bfrick@scf.cc;#supervisorEmail#') />
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")#';
                    retObj.Message = 'Error updating the Rosetta Stone record: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error: Error updating the Rosetta Stone record", retObj.Message);            
                    return retObj;
                </cfscript>
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
       
    <cffunction name="TerminationCompletion" access="public" output="true" returntype="any">
        <cfscript>
            Var retObj = { Status = 'None', Message = '', Result = 0, Trace = 1.0 };
        </cfscript>
        
        <cftry>
            <cfscript>
                import models.*;
                StepAction = entityLoadByPK("StepActions", this.StepAction.getStepActionsID() );
                StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                StepAction.setNotes( 'Auto Generated' );
                StepAction.setActionByID( Session.UserRosettaID );
                EntitySave( StepAction );
            </cfscript>
                        
            <cfif Not this.Scheduled AND Not this.SysScheduled >
            
                <cfscript>
                    InsertHomeFolderTerm = EntityNew("ArchivedFolderTermSchedule");
                    InsertHomeFolderTerm.setArchivedFolder( '#this.ARCHIVEDIR#' );
                    InsertHomeFolderTerm.setCompleted( 0 );
                    InsertHomeFolderTerm.setRosettaID( this.TermDetails.getRosettaID() );
                    InsertHomeFolderTerm.setDeleteDate( DateAdd("yyyy", 1, this.TermDetails.getTermDate()) );
                    InsertHomeFolderTerm.setTermReqID( this.TermReqID );
                    EntitySave(InsertHomeFolderTerm, true);
                    
                    InsertOUTerm = EntityNew("ArchivedUserOUTermSchedule");
                    this.UserDN = GetUserDNArchivedContainer( this.Employee.UserAccount ).UserDN;
                    InsertOUTerm.setArchivedUserOU( '#this.UserDN#' );
                    InsertOUTerm.setCompleted( 0 );
                    InsertOUTerm.setRosettaID( this.TermDetails.getRosettaID() );
                    InsertOUTerm.setDeleteDate( DateAdd("m", 1, this.TermDetails.getTermDate()) );
                    InsertOUTerm.setTermReqID( this.TermReqID );
                    EntitySave(InsertOUTerm, true);
                    
                    for( i=1; i<= ArrayLen(this.TermSchedule); i++){
                        TermSchedule = entityLoadByPK("TerminationSchedule", this.TermSchedule[i].getTermScheduleID() );
                        TermSchedule.setComplete( 1 );
                        EntitySave(TermSchedule);
                    }
                    for( i=1; i<= ArrayLen(this.SysTermSchedule); i++){
                        SysTermSchedule = entityLoadByPK("TerminationSchedule", this.SysTermSchedule[i].getTermScheduleID() );
                        SysTermSchedule.setComplete( 1 );
                        EntitySave(SysTermSchedule);
                    }
                    InsertAction = EntityNew("StepActions");
                    if( this.TermDetails.getNonSCF() EQ 'NO'){
                        InsertAction.setStepsID(24);
                    }else{
                        InsertAction.setStepsID(27);
                    }                    
                    InsertAction.setActionByID( Session.UserRosettaID );
                    InsertAction.setTermReqID( this.TermReqID );
                    InsertAction.setNotes("Moving to Finance Manager Step.");
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    
                    retObj.Status = 'Completed';
                    retObj.Message = "<strong>Termination is complete.</strong>";
                </cfscript>
                
            <cfelseif this.Scheduled OR this.SysScheduled >
                <cfscript>
                    import models.*;
                    InsertAction = EntityNew("StepActions");
                    if(this.TermDetails.getNonSCF() EQ 'NO'){
                        InsertAction.setStepsID(23);
                    }else{
                        InsertAction.setStepsID(27);
                    }
                    InsertAction.setActionByID( Session.UserRosettaID );
                    InsertAction.setTermReqID( this.TermReqID );
                    InsertAction.setNotes("Moving to Scheduled termination queue..");
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    
                    retObj.Status = 'Completed';
                    retObj.Message = "<strong>Termination is complete.</strong>";
                </cfscript>
            <cfelse>
                <cfscript>
                    import models.*;
                    InsertAction = EntityNew("StepActions");
                    if(this.TermDetails.getNonSCF() EQ 'NO'){
                        InsertAction.setStepsID(23);
                    }else{
                        InsertAction.setStepsID(27);
                    }
                    InsertAction.setActionByID( Session.UserRosettaID );
                    InsertAction.setTermReqID( this.TermReqID );
                    InsertAction.setNotes("Moving to Scheduled termination queue.");
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                 
                    retObj.Status = 'Completed';
                    retObj.Message = "<strong>Termination is complete.</strong>";
                </cfscript>
            </cfif>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")# <br />#retObj.Trace#';
                    retObj.Message = 'Error Completing Termination: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error: Error Completing Termination", retObj.Message);            
                    return retObj;
                </cfscript>
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
        
    
    <cffunction name="ScheduledTerminationCompletion" access="public" output="true" returntype="any">
        <cfscript>
            Var retObj = { Status = 'None', Message = '', Result = 0, Trace = 1.0 };
        </cfscript>
        
        <cftry>
            <cfscript>
                import models.*;
                StepAction = entityLoadByPK("StepActions", this.StepAction.getStepActionsID() );
                StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                StepAction.setNotes( 'Termination Complete - Auto Generated' );
                StepAction.setActionByID( Session.UserRosettaID );
                EntitySave( StepAction );
             
                InsertHomeFolderTerm = EntityNew("ArchivedFolderTermSchedule");
                InsertHomeFolderTerm.setArchivedFolder( '#this.ARCHIVEDIR#' );
                InsertHomeFolderTerm.setCompleted( 0 );
                InsertHomeFolderTerm.setRosettaID( this.TermDetails.getRosettaID() );
                InsertHomeFolderTerm.setDeleteDate( DateAdd("yyyy", 1, this.TermDetails.getTermDate()) );
                InsertHomeFolderTerm.setTermReqID( this.TermReqID );
                EntitySave(InsertHomeFolderTerm, true);
                
                InsertOUTerm = EntityNew("ArchivedUserOUTermSchedule");
                this.UserDN = GetUserDNArchivedContainer( this.Employee.UserAccount ).UserDN;
                InsertOUTerm.setArchivedUserOU( '#this.UserDN#' );
                InsertOUTerm.setCompleted( 0 );
                InsertOUTerm.setRosettaID( this.TermDetails.getRosettaID() );
                InsertOUTerm.setDeleteDate( DateAdd("m", 1, this.TermDetails.getTermDate()) );
                InsertOUTerm.setTermReqID( this.TermReqID );
                EntitySave(InsertOUTerm, true);
                
                for( i=1; i<= ArrayLen(this.TermSchedule); i++){
                    TermSchedule = entityLoadByPK("TerminationSchedule", this.TermSchedule[i].getTermScheduleID() );
                    TermSchedule.setComplete( 1 );
                    EntitySave(TermSchedule);
                }
                for( i=1; i<= ArrayLen(this.SysTermSchedule); i++){
                    SysTermSchedule = entityLoadByPK("TerminationSchedule", this.SysTermSchedule[i].getTermScheduleID() );
                    SysTermSchedule.setComplete( 1 );
                    EntitySave(SysTermSchedule);
                }
                InsertAction = EntityNew("StepActions");
                if( this.TermDetails.getNonSCF() EQ 'NO'){
                    InsertAction.setStepsID(24);
                }else{
                    InsertAction.setStepsID(27);
                }                    
                InsertAction.setActionByID( Session.UserRosettaID );
                InsertAction.setTermReqID( this.TermReqID );
                InsertAction.setNotes("Moving to Finance Manager Step.");
                InsertAction.setCreationTimeStamp(now());
                EntitySave(InsertAction, true);
                
                retObj.Status = 'Completed';
                retObj.Message = "<strong>Termination is complete.</strong>";
            </cfscript>
             
            <cfcatch type="any">
                <cfscript>
                    retObj.Status = 'Fail';
                    retObj.Result = ' Message: #replace(CFCATCH.message,"'","\'","all")#<BR/>Detail: #replace(CFCATCH.Detail,"'","\'","all")# <br />#retObj.Trace#';
                    retObj.Message = 'Error Completing Termination: #retObj.Result#<BR /><BR />
                        Step ID: #this.StepAction.getStepActionsID()#<BR />Action by User (Rosetta ID): #Session.UserRosettaID#';
                    ErrorEmail("EPAR Error: Error Completing Termination", retObj.Message);            
                    return retObj;
                </cfscript>
            </cfcatch>                    
        </cftry>
        
        <Cfreturn  retObj />
    </cffunction>
    
    
    <cffunction name="GetUserDNArchivedContainer" access="private" output="false" returntype="any">
        <cfargument name="UserID" type="string" required="false" default="" />
        <cfset Var retVal = {UserDN = "", ArchivedUsersContainer = ""} />
        <cfset SCFAD = CreateObject("component", "code_lib.SCF_ActiveDirectory") />
        <cfset retVal.UserDN = SCFAD.getUserDNByAccountName("#ARGUMENTS.UserID#") />
        <cfset retVal.ArchivedUsersContainer = this.ARCHIVED_USERS_CONTAINER /> 
        <cfreturn retVal />                       
    </cffunction>
    
    
    <cffunction name="ErrorEmail" access="private" output="false" returntype="void">
        <cfargument name="EmailSubject" type="string" required="false" default="EPAR Error" />
        <cfargument name="EmailBody" type="string" required="false" default="" />        
        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="#ARGUMENTS.EmailSubject#" type="html">
            #ARGUMENTS.EmailBody#
	    </cfmail>                
    </cffunction>
        
    
    <cffunction name="ServiceDeskErrorEmail" access="private" output="false" returntype="void">
        <cfargument name="EmailSubject" type="string" required="false" default="EPAR Error" />
        <cfargument name="EmailBody" type="string" required="false" default="" /> 
        <cfset toEmail = 'bfrick@scf.cc' /> <!---SCFITSServiceDeskDL@SouthcentralFoundation.com;    --->  
        <cfmail to=#Session.SERVICEDESK_EMAIL# From="EPAR_Error@scf.cc" subject="#ARGUMENTS.EmailSubject#" type="html">            
            #ARGUMENTS.EmailBody#            
        </cfmail>                
    </cffunction>
    
    
    <cffunction name="AlertEmail" access="public" output="false" returntype="void">
        <cfargument name="EmailSubject" type="string" required="false" default="EPAR Error" />
        <cfargument name="EmailBody" type="string" required="false" default="" />
        <cfargument name="From" type="string" required="false" default="EPAR_Termination@scf.cc" />
        <cfargument name="To" type="string" required="false" default="#Session.SERVICEDESK_EMAIL#" />
        
        <cfmail to=#ARGUMENTS.To# From="#ARGUMENTS.From#" subject="#ARGUMENTS.EmailSubject#" type="html">            
            #ARGUMENTS.EmailBody#            
        </cfmail>                
    </cffunction>

    	
	<cffunction name="funcADDisable" returntype="numeric" access="public">
	    <cfargument name="UserID" type="string" required="yes">
        <cfscript>
            scfad = CreateObject("component", "code_lib.SCF_ActiveDirectory");
            dn = scfad.getUserDNByAccountName( arguments.UserID );
            usePowerShell("Disable-Mailbox #arguments.UserID#@scf.cc -Confirm: $false");
            sleep(6000);
            result = usePowerShell("get-Mailbox -Identity #arguments.UserID#");
            if( result == ""){
                scfad.replaceAttributesByDN( this.UserDN , 'userAccountControl=514');//MSExchHideFromAddressLists=True
                scfad.replaceAttributesByDN( this.UserDN , 'MSExchHideFromAddressLists=True');
                usePowerShell("Get-Mailbox -Identity #arguments.UserID# | Set-Mailbox -HiddenFromAddressListsEnabled $true");
                return 0;
            }else{
                return 1;
            }
        </cfscript>   
	</cffunction>
	
	
	<cffunction name="funcArchiveHomeFolder" returntype="struct" access="public">
	    <cfargument name="Home" type="string" required="yes">
	    <cfargument name="ArchiveDir" type="string" required="yes">
	    <cfset FUNC = {Src = "",Dest = "",ArchResult ="",Result = 0} />
	    
	    <!--- Archive the Home Folder --->      
	    <cfif DirectoryExists(Home)> 
	        <cfdirectory action="list" directory="#ARGUMENTS.Home#" recurse="yes" name="FUNC.Contents" >
	        
	        <cfloop query="FUNC.Contents">
	            <cfset FUNC.Src = FUNC.Contents.Directory & "\" & FUNC.Contents.Name>
	            <cfset FUNC.ArchResult ="Archiving: #FUNC.Src#">
	            <cfset FUNC.Dest = ARGUMENTS.ArchiveDir & "\" & right(FUNC.Src, Len(FUNC.Src) - Len(ARGUMENTS.Home)) />
	            
	            <cfif Type EQ "Dir">
	                <cfdirectory action="create" directory="#FUNC.Dest#">
	            <cfelseif Type EQ "File">
	                <cffile action="copy" source="#FUNC.Src#" destination="#FUNC.Dest#" >
	            </cfif>
	        
	        </cfloop>	                
	            <!--- Delete the Original ---> 
	            <!---<cfdirectory action="delete" directory="#ARGUMENTS.Home#" recurse="yes">--->	 
	            <cfset FUNC.ArchResult ='Archive Complete. Original directory (#ARGUMENTS.Home#) removed.'>       
	    <cfelse>
	        <cfset FUNC.ArchResult = "Directory does not exist #ARGUMENTS.Home#">
	    </cfif>     
	    
	    <cfreturn FUNC>    
	</cffunction>
		
	
	<cffunction name="funcHRTerm" returntype="struct" access="public">
	    <cfargument name="PersonIDNo" type="numeric" required="yes">
	    <cfargument name="EmpStatusIDNo" type="numeric" required="yes">
	    <cfargument name="OrgSCF" type="numeric" required="yes">
	    <cfargument name="RehireElig" type="numeric" required="yes"> <!---BIT--->
	    <cfargument name="TermTypeID" type="numeric" required="yes">
	    <cfargument name="EmpStatusReason" type="numeric" required="yes">
	    <cfargument name="ActionID" type="numeric" required="yes">
	    <cfargument name="Term" type="string" required="yes">
	    <cfargument name="COBRA" type="string" required="yes">
                    
	    <cfset LOCALS.SQL= "scf_SCFVM18_Termination #ARGUMENTS.PersonIDNo#, 
	        #ARGUMENTS.EmpStatusIDNo#, 
	        #ARGUMENTS.OrgSCF#,
	        #ARGUMENTS.RehireElig#,
	        #ARGUMENTS.TermTypeID#,
	        #ARGUMENTS.EmpStatusReason#,
	        #ARGUMENTS.ActionID#,
	        '#ARGUMENTS.Term#',
	        '#ARGUMENTS.COBRA#'" />
	        
	    <cfset thread.SQL = LOCALS.SQL>  <!---Conditional statement in case this function errors out --->
	    
	    <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_Termination"> 
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.PersonIDNo#>                           
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.EmpStatusIDNo#>
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.OrgSCF#>
	        <cfprocparam cfsqltype="cf_sql_bit" value=#ARGUMENTS.RehireElig#>
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.TermTypeID#>
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.EmpStatusReason#>
	        <cfprocparam cfsqltype="cf_sql_integer" value=#ARGUMENTS.ActionID#>
	        <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.Term#">
	        <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.COBRA#">
	        <cfprocresult name="Result1" resultset="1">
	        <cfprocresult name="Result2" resultset="2">
	        <cfprocresult name="Result3" resultset="3">
	        <cfprocresult name="Result4" resultset="4">
	        <cfprocresult name="ErrorCheck" resultset="5">
	    </cfstoredproc>
	    
	    <cfset LOCALS.Result = ErrorCheck.Error>
	        
	    <cfreturn LOCALS />
	    
	</cffunction>
		
	
	<cffunction name="funcDisableTimeKeeper" returntype="void" access="public">
	    <cfargument name="WFCPersonID" type="numeric" required="yes">
	            
	    <!--- Disable TimeKeeper Record --->        
	    <cfquery datasource="#Session.DataSource#" name="qryDisableTK">
	        scf_SCFVM18_RenameKronosUser #ARGUMENTS.WFCPersonID#
	    </cfquery>  
	    
	</cffunction>
		
	
	<cffunction name="funcExportMailbox" returntype="any" access="public">
	    <cfargument name="UserID" type="string" required="yes">
	    <cfscript>
            //return usePowerShell("Export-Mailbox -Identity #arguments.UserID# -PSTFolderPath #this.ArchiveEmailDir#");
            AlertEmail('Export mailbox to pst for user #this.Employee.UserAccount#', 
                "#this.Employee.FirstName# #this.Employee.LastName# needs their email account exported to a pst file to complete their termination.  Please export the file to #this.ArchiveEmailDir#.",
                "EPAR_Termiantion@scf.cc",
                "bfrick@scf.cc");//servicedesk@scf.cc;
        </cfscript>        
	</cffunction>
		
	
	<cffunction name="funcArchiveAndDisable" returntype="any" access="public">
	    <cfargument name="UserID" type="string" required="yes">
        <cfscript>
            scfad = CreateObject("component", "code_lib.SCF_ActiveDirectory");
            scfad.replaceAttributesByDN( this.UserDN, 'userAccountControl=#JavaCast("int", 514)#');
            usePowerShell('
                $user = [ADSI]"LDAP://#this.UserDN#"
                $user.Invoke("setpassword", "Password10!")
            ');
            //move to Archived OU
            result = usePowerShell('
                $objectlocation= "#this.UserDN#"
                $from = new-object System.DirectoryServices.DirectoryEntry("LDAP://$objectLocation")
                $newlocation = "#this.ARCHIVED_USERS_CONTAINER#"
                $to = new-object System.DirectoryServices.DirectoryEntry("LDAP://$newlocation")
                $from.MoveTo($to.Path)
            ');
            if( result EQ "" ){ 
                return 0; 
            }else{ 
                return 1;
            }
        </cfscript>
	</cffunction>
		
	
	<cffunction name="funcDisableRosetta" returntype="void" access="public">
	    <cfargument name="RosettaID" type="string" required="yes">
        <cfscript>
            import models.*;
            Rosetta = entityLoadByPK("RosettaStone", arguments.RosettaID );
            Rosetta.setDisabled( 1 );
            entitySave(Rosetta);            
        </cfscript>
	</cffunction>
   
    
    <cffunction name="usePowerShell" access="public" output="false" returntype="any">
        <cfargument name="PSCommands" type="string" default="get-mailbox XXXTestXXX | out-string -width 10000" />
        <cfscript>
            powershell = CreateObject("webservice", "http://scfcas/PowerShellService/?WSDL", {username = 'SCF\Userlist', password = 'DefinedMan'});
            result = powershell.Invoke(
                'add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin
                #arguments.PSCommands#'
            );
            return result;
        </cfscript>  
    </cffunction>
    
</cfcomponent>